<template>
  <div class="designreg-main"> 
	<section class="featured-block text-center">
		<div class="container">
			
		<div>
			用户名：<input type="text" v-model="name">
		</div>

		<br><br>
		
		<div>
			密码：<input type='password' v-model="password">
		</div>

		<br><br>

		<!-- ui专属控件 -->
		<Button @click="set_reg">登录</Button>
		</div>
	</section>
  </div>
  
</template>

<script>
export default {
    name:'designreg',
    data(){
        return {
            bgImg: {
                backgroundImage: "url(" + require("../log/sk.png")+")",
                backgroundRepeat: "no-repeat",
                backgroundSize: '100% auto'
            },
            name: '',
            password: '',
            width:300,
	        height:42,
        }
    },

    methods: {
        reg(){
            this.axios.get('/api/login',{params: {name:this.name, password: this.password}}).then((res)=>{
            console.log(res)
            this.$Message(res.data.msg)
            //判断返回信息状态
            if(res.data.code==200){
                //在本地保存  uid  username
                localStorage.setItem('name',this.name)

                //跳转首页
                this.$router.push('/content')
            }else{
                this.$Message(res.data.msg)
            }
        }) 
        },

        set_reg(){
            if(this.name === '' || this.password === ''){
                this.$Message('用户名或密码不能为空')
                return
            }
            this.reg()
        }
    },
    
}
</script>
<style scoped>
.designreg-main{
    width: 100%;
    height: 100vh;
    background-image: url('../log/sk.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
}
</style>

